package com.ruoyi.teacher.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.teacher.domain.SysCollege;
import com.ruoyi.teacher.mapper.SysCollegeMapper;
import com.ruoyi.teacher.service.ISysCollegeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.validation.Validator;
import java.util.List;

/**
 * sysCollegeService业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@Service
public class SysCollegeServiceImpl implements ISysCollegeService
{
    private static final Logger log = LoggerFactory.getLogger(SysCollegeServiceImpl.class);
    @Autowired
    protected Validator validator;
    @Autowired
    private SysCollegeMapper sysCollegeMapper;

    /**
     * 查询sysCollege
     * 
     * @param id sysCollege主键
     * @return sysCollege
     */
    @Override
    public SysCollege selectSysCollegeById(Long id)
    {
        return sysCollegeMapper.selectSysCollegeById(id);
    }

    /**
     * 查询sysCollege列表
     * 
     * @param sysCollege sysCollege
     * @return sysCollege
     */
    @Override
    public List<SysCollege> selectSysCollegeList(SysCollege sysCollege)
    {
        return sysCollegeMapper.selectSysCollegeList(sysCollege);
    }

    /**
     * 新增sysCollege
     * 
     * @param sysCollege sysCollege
     * @return 结果
     */
    @Override
    public int insertSysCollege(SysCollege sysCollege)
    {
        return sysCollegeMapper.insertSysCollege(sysCollege);
    }

    /**
     * 修改sysCollege
     * 
     * @param sysCollege sysCollege
     * @return 结果
     */
    @Override
    public int updateSysCollege(SysCollege sysCollege)
    {
        return sysCollegeMapper.updateSysCollege(sysCollege);
    }

    /**
     * 批量删除sysCollege
     * 
     * @param ids 需要删除的sysCollege主键
     * @return 结果
     */
    @Override
    public int deleteSysCollegeByIds(String ids)
    {
        return sysCollegeMapper.deleteSysCollegeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除sysCollege信息
     * 
     * @param id sysCollege主键
     * @return 结果
     */
    @Override
    public int deleteSysCollegeById(Long id)
    {
        return sysCollegeMapper.deleteSysCollegeById(id);
    }

    @Override
    public List<SysCollege> selectCollegeAll() {
        return sysCollegeMapper.selectCollegeAll();
    }

    @Override
    public List<SysCollege> selectCollegesByCollegeId(Long collegeId) {
        List<SysCollege> list =  selectCollegeAll();
        for(SysCollege sysCollege:list){
             if(sysCollege.getId()==collegeId){
                 sysCollege.setFlag(true);
                 break;
             }
        }
        return list;
    }
}
